package com.test.mytest.saolei.swing;

import javax.swing.BorderFactory;
import javax.swing.JLabel;

public class BoomLabel extends JLabel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	public BoomLabel(String text) {
		super(text);
	}
	private int boomSize=0;
	private int wSize=0;
	private int hSize=0;
	private boolean willBoom=false;
	private boolean isOpen=false;

	public int getBoomSize() {
		return boomSize;
	}

	public void setBoomSize(int boomSize) {
		this.boomSize = boomSize;
	}


	public boolean isWillBoom() {
		return willBoom;
	}

	public void setWillBoom(boolean willBoom) {
		this.willBoom = willBoom;
		if (willBoom) {
			setText("*");
		}else{
			setText("");
		}
	}

	public void open() {
		setBorder(BorderFactory.createEtchedBorder());
		if (boomSize==0) {
			setText("");
		}else if(boomSize<10){
			setText(""+boomSize);
		}else{
			setText("B");
		}
		isOpen=true;
	}

	public int getwSize() {
		return wSize;
	}

	public void setwSize(int wSize) {
		this.wSize = wSize;
	}

	public int gethSize() {
		return hSize;
	}

	public void sethSize(int hSize) {
		this.hSize = hSize;
	}
	
	@Override
	public String toString() {
		return "wSize:"+wSize+"=hSize:"+hSize+"=boomSize:"+boomSize;
	}

	public boolean isOpen() {
		return isOpen;
	}

	public void setOpen(boolean isOpen) {
		this.isOpen = isOpen;
		firePropertyChange("isOpen", null, null);
	}
}
